package com.xbongbong.pro.enums.businessrule.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 业务规则，值类型封装
 * @author 吴峰
 * @version v1.0
 * @date 2019/12/9 14:43
 * @since v1.0
 */
@Getter
public enum RuleValueTypeEnum {

    /**
     * 动态值
     */
    DYNAMIC_VALUE(1, "enum.ruleValueType.name.dynamic_value"),

    /**
     * 固定值
     */
    FIXED_VALUE(2, "enum.ruleValueType.name.fixed_value"),



    UNKNOW(404, ""),
    ;

    private Integer type;

    private String name;

    RuleValueTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static RuleValueTypeEnum getByType(Integer type){
        for (RuleValueTypeEnum ruleValueTypeEnum : values()) {
            if (ruleValueTypeEnum.getType().equals(type)) {
                return ruleValueTypeEnum;
            }
        }
        return null;
    }
}
